<!doctype html>
<html class="no-js" lang="zxx" xmlns:th="http://www.thymeleaf.org">
<head th:replace="comm/comm::user-head"></head>
<body>
<header>
    <div th:replace="comm/comm::user-top"></div>
</header>
    <main>
        <!-- Register Area Start -->
        <div class="register-form-area section-padding" id="app">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-xl-6 col-lg-7 col-md-10">
                        <div class="register-form text-center">
                            <!-- Login Heading -->
                            <div class="register-heading">
                                <span>注册</span>
                                <p>欢迎使用</p>
                            </div>
                            <!-- Single Input Fields -->
                            <div class="input-box">
                                <div class="single-input-fields">
                                    <label>用户名</label>
                                    <input type="text" v-model="username" placeholder="用户名">
                                </div>
                                <div class="single-input-fields">
                                    <label>密码</label>
                                    <input type="password" v-model="password" placeholder="密码">
                                </div>
                            </div>
                            <!-- form Footer -->
                            <div class="register-footer">
                                <p> 有账户? 点击<a href="/user/userLogin"> 登录</a> 这</p>
                                <button class="btn login-btn" @click="addUser">注册</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Register Area End -->
    </main>
    <!-- Scroll Up -->
    <div id="back-top" >
        <a title="Go to Top" href="#"> <i class="fas fa-level-up-alt"></i></a>
    </div>

    <!-- JS here -->
    <!-- Jquery, Popper, Bootstrap -->
    <div th:replace="comm/comm::user-js"></div>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                username:'',
                password:''
            },
            methods:{
                addUser(){
                    let formData = new FormData()
                    formData.append('username',this.username)
                    formData.append('password',this.password)
                    axios.post('/user/userRegister',formData).then(res=>{
                        if (res.data){
                            alert('注册成功 请登录')
                            location.href = '/user/userLogin'
                        }
                    })
                }
            }
        })
    </script>
</body>
</html>